import { defineStore } from 'pinia'
import { ref } from 'vue'

// 媒体数据
export const useMediaStore = defineStore(
  'media',
  () => {
    // 窗口数据
    enum Screen {
      top = '24px',
      width = '360px',
      height = '568px',
      allHeight = '592px',
    }
    // 请求基地址
    const baseURL = ref('http://192.168.110.249/mt')
    // 记得 return
    return {
      Screen,
      baseURL,
    }
  },
  {
    // 配置持久化
    persist: {
      // 调整为兼容多端的API
      storage: {
        setItem(key, value) {
          uni.setStorageSync(key, value)
        },
        getItem(key) {
          return uni.getStorageSync(key)
        },
      },
      paths: ['baseURL'],
    },
  },
)
